package cn.bugstack.springframework.aop.framework;


import cn.bugstack.springframework.aop.AdvisedSupport;

/**
 * 代理工厂
 */
public class ProxyFactory {
    AdvisedSupport advisedSupport;

    public ProxyFactory(AdvisedSupport advisedSupport) {
        this.advisedSupport = advisedSupport;
    }

    public Object getProxy(){
        return createAopProxy().getProxy();
    }

    public AopProxy createAopProxy(){
        if(advisedSupport.isProxyTargetClass()){
            return new Cglib2AopProxy(advisedSupport);
        }
        return new JdkDynamicAopProxy(advisedSupport);
    }




}
